
package com.lyyzoo.service;

import com.lyyzoo.data.dao.BaseDao;
import com.lyyzoo.data.domain.Page;
import com.lyyzoo.data.entity.BaseEntity;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class BaseService<T extends BaseEntity> {
    @Autowired
    protected BaseDao<T> dao;

    public BaseService() {
    }

    public BaseDao<T> getDao() {
        return this.dao;
    }

    public void setDao(BaseDao<T> dao) {
        this.dao = dao;
    }

    public <S extends T> S save(S entity) {
        return this.dao.save(entity);
    }

    public <S extends T> List<S> save(Iterable<S> entities) {
        return this.dao.save(entities);
    }

    public <S extends T> S update(S entity) {
        return this.dao.update(entity);
    }

    public <S extends T> List<S> update(Iterable<S> entities) {
        return this.dao.update(entities);
    }

    public <S extends T> S saveOrUpdate(S entity) {
        return this.dao.saveOrUpdate(entity);
    }

    public <S extends T> List<S> saveOrUpdate(Iterable<S> entities) {
        return this.dao.saveOrUpdate(entities);
    }

    public void delete(Long id) {
        this.dao.delete(id);
    }

    public void delete(Long[] ids) {
        this.dao.delete(ids);
    }

    public void delete(T entity) {
        this.dao.delete(entity);
    }

    public void delete(Iterable<T> entities) {
        this.dao.delete(entities);
    }

    public T get(Long id) {
        return this.dao.get(id);
    }

    public T get(Map<String, Object> filter) {
        return this.dao.get(filter);
    }

    public List<T> find() {
        return this.dao.find();
    }

    public List<T> find(String key, Object value) {
        return this.dao.find(key, value);
    }

    public List<T> find(Map<String, Object> filter) {
        return this.dao.find(filter);
    }

    public Page<T> page(int pageNumber, int pageSize) {
        return this.dao.page(pageNumber, pageSize);
    }

    public Page<T> page(Map<String, Object> filter, int pageNumber, int pageSize) {
        return this.dao.page(filter, pageNumber, pageSize);
    }

    public Long getCount() {
        return this.dao.getCount();
    }

    public Long getCount(Map<String, Object> filter) {
        return this.dao.getCount(filter);
    }
}
